package com.lrr.community.mapper;

import com.lrr.community.dto.QuestionDto;
import com.lrr.community.model.Question;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface QuestionMapper {
    @Insert("insert into question(title,description,gmt_create,gmt_modified,createor,tag) " +
            "values (#{title},#{description},#{gmt_create},#{gmt_modified},#{createor},#{tag})")
    public void create(Question question);
    @Select("select * from question")
    List<Question> list1();


    @Select("select * from question limit #{offset},#{size} ")
    List<Question> list(@Param("offset") Integer offset, @Param("size") Integer size);

    @Select("select count(1) from question")
    Integer count();

    @Select("select * from question where createor=#{userId} limit #{offset},#{size} ")
    List<Question> listById(@Param("userId") int userId, @Param("offset") Integer offset, @Param("size") Integer size);

    @Select("select count(1) from question where createor=#{userId}")
    Integer countById(@Param("userId") int userId);

    @Select("select * from question where id=#{id}")
    Question getById(@Param("id") Integer id);

    @Update("update question set title=#{title}, description=#{description},gmt_modified=#{gmt_modified}," +
            "tag=#{tag} where id=#{id}")
    void update(Question question);
}
